package control;

import java.util.ArrayList;

import db.DBRenter;
import model.Apartment;
import model.Renter;
import model.RenterStatus;

public class CtrRenter {

	private DBRenter dbr;
	public CtrRenter()
	{
		dbr = new DBRenter();
	}
	
	public Renter getRenter(int id)
	{
		Renter r = this.dbr.getById(id);
		return r;
	}
	
	public void setMoveInStatus(Renter r)
	{
		r.setStatus(RenterStatus.ACTIVE);
		this.dbr.update(r);
	}
	
	public void setMoveOutStatus(Renter r)
	{
		r.setStatus(RenterStatus.MOVEDOUT);
		this.dbr.update(r);
	}
	
	public ArrayList<Renter>  getAll(){
		return this.dbr.getAll();
	}
	/*
	public ArrayList<Renter> findRenter(String firstName, String lastName)
	{
		ArrayList<Renter> r = this.dbr.getByName(firstName, lastName);
		return r;
	}
*/

	public Renter createRenter(String firstName, String lastName,String 
			cpr,String mobilePhone, String privatePhone, String address,
			String email, String occupation, String workplace)
	{
		Renter r = new Renter();
		r.setAddress(address);
		r.setCpr(cpr);
		r.setEmail(email);
		r.setFirstName(firstName);
		r.setLastName(lastName);
		r.setMobilePhone(mobilePhone);
		r.setOccupation(occupation);
		r.setPrivatePhone(privatePhone);
		r.setWorkplace(workplace);
		r.setStatus(RenterStatus.WAITING);
		r.setId(this.dbr.insertScope(r));
		return r;
	}
}
